//
// Created by LYS on 2022/2/23.
//

#include<iostream>
using  namespace std;

typedef long long ll;

const int MAX_N = 10000000+10;

// [1,n]
int bit[MAX_N],n;

// compute the sum of 1-i
int sum(int i){
    int s = 0;
    while(i>0){
        s+= bit[i];
        i -= i & -i;
    }
    return s;
}

// add x to  value of the i-th node
void add(int i,int x){
    while(i<=n){
        bit[i]+=x;
        i += i & -i;
    }
}

void solve(){
    ll ans = 0;
    int t;
    cin >> n;
    for(int i=1;i<=n;i++){
        cin >> t;
        ans += i - 1 - sum(t);
        add(t,1);
    }
    cout << ans;
}

int main(){
    freopen("data.in","r",stdin);
    freopen("data.out","w",stdout);
    solve();
    return 0;
}